window.onload = function() {
	var pullUpWrap = {
		pages: {
			page: 0,
			pageRow: 10,
			refreshPage: function() {
				this.page = 0;
				this.endPage = 0;
			},
			getPageObj: function() {
				var that = this;
				return {
					startPage: that.page * that.pageRow,
					endPage: that.endPage * that.pageRow,
					pageRow: that.pageRow
				}
			},
			updatePage: function() {
				this.page++;
				this.endPage++;
			}
		}
	}
	var pullUpWrapObj = pullUpWrap.pages.getPageObj();
	var start = pullUpWrapObj.startPage;
	var pageRow = pullUpWrapObj.pageRow;
	mui.ajax({
		"url": URL_all+"client/orderinfo/selectbyuserid?page=1&pagesize=11",
		"dataType": "json",
		"type": "POST",
		"timeout": 10000000000,
		"data": {
			'page': start,
			'pagerow': pageRow,
			'sorting': "generate_time",
			'tosort': "desc"
		},
		"headers": {
			'userToken': localStorage.userToken,
			'Content-Type': 'application/json'
		},
		"success": function(data) {
			var content = document.getElementsByClassName("content")[0];
			var html = "";
			//		var data = data.pageInfo.list.orderCommodityVo.list;
			var orderData = data.dataResultList;
			for(var index in orderData) {
				var orderCommodity = orderData[index].orderCommodityVo,
					orderNumber = orderData[index].orderNumber,
					payment_state = orderData[index].paymentState,
					order_state = orderData[index].orderState,
					order_process = orderData[index].orderProcess;
				contact_Name = orderData[index].contactName;
				allcountNum = 0;
				var totalPrice = 0;
				for(var i in orderCommodity) {
					if(i == 0) {
						html += '<div class="detail_top clearfix" orderNumber="' + orderNumber + '">';
					}
					//	            var photo = SYSTEM_IMG_HOST + orderCommodity[i].list[0].withGiftIcon,
					id = orderCommodity[i].commodityNumber,
						title = '';
					if(orderCommodity[i].list.length == 0) {
						title = '';
						presentPrice = '';
						originalPrice = '';
						photo = '';
					} else {
						title = orderCommodity[i].list[0].title;
						presentPrice = orderCommodity[i].list[0].presentPrice / 100;
						originalPrice = orderCommodity[i].list[0].originalPrice / 100;
						photo = IMGUrl + '' + orderCommodity[i].list[0].mainPhoto;
					}
					//	                title = orderCommodity[i].list[1].title;
					countNum = orderCommodity[i].buyAmount;
					allcountNum += countNum;
					totalPrice += +countNum * +presentPrice;
					//	                if (productCode.indexOf(id) == -1) {//防止商品编号重复
					//	                    productCode.push(id);
					//	                    console.log(productCode);
					//	                }
					if(contact_Name == null) {
						contact_Name = '无';
					}
					html += '<div class="details_text mui-col-xs-8" >' +
						'<div class="details_img mui-col-xs-4"><img src="' + photo + '" width="100%"></div>' +
						'<p>' + title + '<span>￥' + presentPrice + '</span></p>' +
						'<p><span class="huaxian">￥' + originalPrice + '</span></p>' +
						'<p class="count">x' + countNum + '</p>' +
						'<span class="mark">' + contact_Name + '</span>' +
						'</div>';
				}
				html += '<div class="bottom_text red fright">退款金额：' + totalPrice + '</div></div>';
				allcountNum = 0;
				//				html += switchPayment(payment_state,order_state);
			}
			//			if(isCover){
			//				content.innerHTML = html;
			//			}else{
			content.innerHTML = html;
			//			}
		}
	})
}